﻿@model MvcMovieCollection.Models.AddGenre

@{
    ViewBag.Title = "AddGenre";
}

<h1>Add Genre</h1>


<h4>Use the form below to add a new Genre to your Database. 
Newly added genres will be available in the picker for add movies.</h4>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{ 
    <div>
        <fieldset>
            <legend>Add a New Genre</legend>
            
            @Html.ValidationSummary(true)
            <div class="editor-label">
                @Html.LabelFor(m => m.Name)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Name)
                @Html.ValidationMessageFor(m => m.Name)
            </div>

            <p>
                <input type="submit", value="Add New Genre" />
            </p>

        </fieldset>
    </div>
}

<table class="Genres">
    <tr>
        <th></th>
        <th>Genre</th>
    </tr>

    @foreach (MvcMovieCollection.Models.Genres genre in ViewBag.ModelListGenres)
    {  
        if(genre == ViewBag.ModelListGenres[0])
        {
            continue;
        }       
        <tr>
            <td><h4>@Html.ActionLink("Delete", "DeleteGenre", new { id = genre.ID })</h4></td>
            <td><h4>@genre.Name</h4></td>
        </tr>
    }
</table>